package com.bestcem.xm.component.grpcmetrics.configure;

import com.bestcem.xm.component.grpcmetrics.aspect.GrpcMetricAspect;
import com.bestcem.xm.component.grpcmetrics.properties.GrpcMetricProperties;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
@EnableConfigurationProperties({GrpcMetricProperties.class})
@ConditionalOnProperty(prefix = "xm.grpc.metrics", name = "enabled", havingValue = "true", matchIfMissing = false)
public class GrpcMetricsAutoConfigure {
    @Bean
    @ConditionalOnMissingBean
    public GrpcMetricAspect grpcMetricAspect() {
        return new GrpcMetricAspect();
    }
}
